from collections import defaultdict

instruction_list = lambda:defaultdict(instruction_list)
instruction_table = instruction_list()

# RV32I
## Branch
instruction_table['0x18']['0'] = 'beq'
instruction_table['0x18']['1'] = 'bne'
instruction_table['0x18']['4'] = 'blt'
instruction_table['0x18']['5'] = 'bge'
instruction_table['0x18']['6'] = 'bltu'
instruction_table['0x18']['7'] = 'bgeu'
## Jump
instruction_table['0x19'] = 'jalr'
instruction_table['0x1b'] = 'jal'
## Upper Immediate
instruction_table['0x0d'] = 'lui'
instruction_table['0x05'] = 'auipc'
## Arithmetic & Computation Immediate
instruction_table['0x04']['0'] = 'addi'
instruction_table['0x04']['1'] = 'slli'
instruction_table['0x04']['2'] = 'slti'
instruction_table['0x04']['3'] = 'sltiu'
instruction_table['0x04']['4'] = 'xori'
instruction_table['0x04']['5']['0'] = 'srli'
instruction_table['0x04']['5']['16'] = 'srai'
instruction_table['0x04']['6'] = 'ori'
instruction_table['0x04']['7'] = 'andi'
## Arithmetic & Computation Register to Register
instruction_table['0x0c']['0']['0'] = 'add'
instruction_table['0x0c']['0']['32'] = 'sub'
instruction_table['0x0c']['1']['0'] = 'sll'
instruction_table['0x0c']['2']['0'] = 'slt'
instruction_table['0x0c']['3']['0'] = 'sltu'
instruction_table['0x0c']['4']['0'] = 'xor'
instruction_table['0x0c']['5']['0'] = 'srl'
instruction_table['0x0c']['5']['32'] = 'sra'
instruction_table['0x0c']['6']['0'] = 'or'
instruction_table['0x0c']['7']['0'] = 'and'
## Extended Arithmetic & Computation Immediate
instruction_table['0x06']['0'] = 'addiw'
instruction_table['0x06']['1'] = 'slliw'
instruction_table['0x06']['5']['0'] = 'srliw'
instruction_table['0x06']['5']['16'] = 'sraiw'
## Extended Arithmetic & Computation Register to Register
instruction_table['0x0e']['0']['0'] = 'addw'
instruction_table['0x0e']['0']['32'] = 'subw'
instruction_table['0x0e']['1']['0'] = 'sllw'
instruction_table['0x0e']['5']['0'] = 'srlw'
instruction_table['0x0e']['5']['32'] = 'sraw'
## Load
instruction_table['0x00']['0'] = 'lb'
instruction_table['0x00']['1'] = 'lh'
instruction_table['0x00']['2'] = 'lw'
instruction_table['0x00']['3'] = 'ld'
instruction_table['0x00']['4'] = 'lbu'
instruction_table['0x00']['5'] = 'lhu'
instruction_table['0x00']['6'] = 'lwu'
## Store
instruction_table['0x08']['0'] = 'sb'
instruction_table['0x08']['1'] = 'sh'
instruction_table['0x08']['2'] = 'sw'
instruction_table['0x08']['3'] = 'sd'
## Fence
instruction_table['0x03']['0'] = 'fence'
instruction_table['0x03']['1'] = 'fence.i'
# RV32M
instruction_table['0x0c']['0']['1'] = 'mul'
instruction_table['0x0c']['1']['1'] = 'mulh'
instruction_table['0x0c']['2']['1'] = 'mulhsu'
instruction_table['0x0c']['3']['1'] = 'mulhu'
instruction_table['0x0c']['4']['1'] = 'div'
instruction_table['0x0c']['5']['1'] = 'divu'
instruction_table['0x0c']['6']['1'] = 'rem'
instruction_table['0x0c']['7']['1'] = 'remu'
# RV64M
instruction_table['0x0e']['0']['1'] = 'mulw'
instruction_table['0x0e']['4']['1'] = 'divw'
instruction_table['0x0e']['5']['1'] = 'divuw'
instruction_table['0x0e']['6']['1'] = 'remw'
instruction_table['0x0e']['7']['1'] = 'remuw'

# RV32A
instruction_table['0x0b']['2']['0']['0'] = 'amoadd.w'
instruction_table['0x0b']['2']['0']['1'] = 'amoxor.w'
instruction_table['0x0b']['2']['0']['2'] = 'amoor.w'
instruction_table['0x0b']['2']['0']['3'] = 'amoand.w'
instruction_table['0x0b']['2']['0']['4'] = 'amomin.w'
instruction_table['0x0b']['2']['0']['5'] = 'amomax.w'
instruction_table['0x0b']['2']['0']['6'] = 'amominu.w'
instruction_table['0x0b']['2']['0']['7'] = 'amomaxu.w'
instruction_table['0x0b']['2']['1']['0'] = 'amoswap.w'
instruction_table['0x0b']['2']['2']['0'] = 'lr.w'
instruction_table['0x0b']['2']['3']['0'] = 'sc.w'
# RV64A
instruction_table['0x0b']['3']['0']['0'] = 'amoadd.d'
instruction_table['0x0b']['3']['0']['1'] = 'amoxor.d'
instruction_table['0x0b']['3']['0']['2'] = 'amoor.d'
instruction_table['0x0b']['3']['0']['3'] = 'amoand.d'
instruction_table['0x0b']['3']['0']['4'] = 'amomin.d'
instruction_table['0x0b']['3']['0']['5'] = 'amomax.d'
instruction_table['0x0b']['3']['0']['6'] = 'amominu.d'
instruction_table['0x0b']['3']['0']['7'] = 'amomaxu.d'
instruction_table['0x0b']['3']['1']['0'] = 'amoswap.d'
instruction_table['0x0b']['3']['2']['0'] = 'lr.d'
instruction_table['0x0b']['3']['3']['0'] = 'sc.d'
# F/D EXTENSIONS
instruction_table['0x14']['0']['0'] = 'fadd.s'
instruction_table['0x14']['1']['0'] = 'fsub.s'
instruction_table['0x14']['2']['0'] = 'fmul.s'
instruction_table['0x14']['3']['0'] = 'fdiv.s'
instruction_table['0x14']['11']['0'] = 'fsqrt.s'
instruction_table['0x14']['4']['0']['0'] = 'fsgnj.s'
instruction_table['0x14']['4']['0']['1'] = 'fsgnjn.s'
instruction_table['0x14']['4']['0']['2'] = 'fsgnjx.s'
instruction_table['0x14']['5']['0']['0'] = 'fmin.s'
instruction_table['0x14']['5']['0']['1'] = 'fmax.s'

instruction_table['0x14']['0']['1'] = 'fadd.d'
instruction_table['0x14']['1']['1'] = 'fsub.d'
instruction_table['0x14']['2']['1'] = 'fmul.d'
instruction_table['0x14']['3']['1'] = 'fdiv.d'
instruction_table['0x14']['8']['0'] = 'fcvt.s.d'
instruction_table['0x14']['8']['1'] = 'fcvt.d.s'
instruction_table['0x14']['11']['1'] = 'fsqrt.d'
instruction_table['0x14']['4']['1']['0'] = 'fsgnj.d'
instruction_table['0x14']['4']['1']['1'] = 'fsgnjn.d'
instruction_table['0x14']['4']['1']['2'] = 'fsgnjx.d'
instruction_table['0x14']['5']['1']['0'] = 'fmin.d'
instruction_table['0x14']['5']['1']['1'] = 'fmax.s'

instruction_table['0x14']['20']['0']['0'] = 'fle.s'
instruction_table['0x14']['20']['0']['1'] = 'flt.s'
instruction_table['0x14']['20']['0']['2'] = 'feq.s'

instruction_table['0x14']['20']['1']['0'] = 'fle.d'
instruction_table['0x14']['20']['1']['1'] = 'flt.d'
instruction_table['0x14']['20']['1']['2'] = 'feq.d'

instruction_table['0x14']['24']['0']['0'] = 'fcvt.w.s'
instruction_table['0x14']['24']['0']['1'] = 'fcvt.wu.s'
instruction_table['0x14']['24']['0']['2'] = 'fcvt.l.s'
instruction_table['0x14']['24']['0']['3'] = 'fcvt.lu.s'
instruction_table['0x14']['28']['0']['0']['0'] = 'fmv.x.s'
instruction_table['0x14']['28']['0']['0']['1'] = 'fclass.s'

instruction_table['0x14']['24']['1']['0'] = 'fcvt.w.d'
instruction_table['0x14']['24']['1']['1'] = 'fcvt.wu.d'
instruction_table['0x14']['24']['1']['2'] = 'fcvt.l.d'
instruction_table['0x14']['24']['1']['3'] = 'fcvt.lu.d'
instruction_table['0x14']['28']['1']['0']['0'] = 'fmv.x.d'
instruction_table['0x14']['28']['1']['0']['1'] = 'fclass.d'

instruction_table['0x14']['26']['0']['0'] = 'fcvt.s.w'
instruction_table['0x14']['26']['0']['1'] = 'fcvt.s.wu'
instruction_table['0x14']['26']['0']['2'] = 'fcvt.s.l'
instruction_table['0x14']['26']['0']['3'] = 'fcvt.s.lu'

instruction_table['0x14']['26']['1']['0'] = 'fcvt.d.w'
instruction_table['0x14']['26']['1']['1'] = 'fcvt.d.wu'
instruction_table['0x14']['26']['1']['2'] = 'fcvt.d.l'
instruction_table['0x14']['26']['1']['3'] = 'fcvt.d.lu'

instruction_table['0x14']['30']['0']['0'] = 'fmv.s.x'
instruction_table['0x14']['30']['1']['0'] = 'fmv.d.x'

instruction_table['0x01']['2'] = 'flw'
instruction_table['0x01']['3'] = 'fld'

instruction_table['0x09']['2'] = 'fsw'
instruction_table['0x09']['3'] = 'fsd'

instruction_table['0x10']['0'] = 'fmadd.s'
instruction_table['0x11']['0'] = 'fmsub.s'
instruction_table['0x12']['0'] = 'fnmsub.s'
instruction_table['0x13']['0'] = 'fnmadd.s'

instruction_table['0x10']['1'] = 'fmadd.d'
instruction_table['0x11']['1'] = 'fmsub.d'
instruction_table['0x12']['1'] = 'fnmsub.d'
instruction_table['0x13']['1'] = 'fnmadd.d'
# SYSTEM
instruction_table['0x1c']['0']['0'] = 'ecall'
instruction_table['0x1c']['0']['1'] = 'ebreak'
instruction_table['0x1c']['0']['2'] = 'uret'
instruction_table['0x1c']['0']['258'] = 'sret'
instruction_table['0x1c']['0']['514'] = 'hret'
instruction_table['0x1c']['0']['770'] = 'mret'
instruction_table['0x1c']['0']['260'] = 'sfence.vm'
instruction_table['0x1c']['0']['261'] = 'wfi'

instruction_table['0x1c']['1'] = 'csrrw'
instruction_table['0x1c']['2'] = 'csrrs'
instruction_table['0x1c']['3'] = 'csrrc'
instruction_table['0x1c']['5'] = 'csrrwi'
instruction_table['0x1c']['6'] = 'csrrsi'
instruction_table['0x1c']['7'] = 'csrrci'
